import db from '@/utils/localstorage'

export default {
  namespaced: true,
  state: {
    warningDialog: db.get('Global_WarningDialog'), // 手动报警 弹窗
    refreshWarningList: db.get('Refresh_WarningList'), // 手动报警 自动报警 刷新告警列表
    // 防疫管理 数据统计页面
    healthCodeStatisticsData: db.get('HealthCode_Statistics_Data') || [], //  健康码统计
    temperatureStatisticsData: db.get('temperature_Statistics_Data') || [], //  体温统计
    visitorSourceStatisticsData: db.get('visitorSource_Statistics_Data') || [], //  访客来源
    visitorsRecordStatisticsData: db.get('visitorRecord_Statistics_Data') || [], //  访客记录
    alertInfoStatisticsData: db.get('alertInfo_Statistics_Data') || {}, //  异常数据
    isReplacePlan: db.get('is_replace_plan') || false, //  异常数据
  },
  mutations: {
    setWarningDialog (state, val) {
      db.save('Global_WarningDialog', val)
      state.warningDialog = val
    },
    setRefreshWarningList (state, val) {
      db.save('Refresh_WarningList', val)
      state.refreshWarningList = val
    },
    setHealthCodeStatisticsData (state, val) {
      db.save('HealthCode_Statistics_Data', val)
      state.healthCodeStatisticsData = val
    },
    setTemperatureStatisticsData (state, val) {
      db.save('temperature_Statistics_Data', val)
      state.temperatureStatisticsData = val
    },
    setVisitorSourceStatisticsData (state, val) {
      db.save('visitorSource_Statistics_Data', val)
      state.visitorSourceStatisticsData = val
    },
    setVisitorRecordStatisticsData (state, val) {
      db.save('visitorRecord_Statistics_Data', val)
      state.visitorsRecordStatisticsData = val
    },
    setAlertInfoStatisticsData(state, val) {
      db.save('alertInfo_Statistics_Data', val)
      state.alertInfoStatisticsData = val
    },

    setIsReplacePlan(state, val) {
      db.save('is_replace_plan', val)
    
      state.isReplacePlan = val
      console.log('state.isReplacePlan=',state.isReplacePlan)
    }
  }
}
